<template>
	<view>
		<view style="width: 750rpx;height: 312rpx;position: relative;">
			<image :src="img" style="width: 750rpx;height: 312rpx;vertical-align: middle;"></image>
			<view style="position: absolute;top: 55rpx;left: 55rpx;">
				<view>
					<text style="color: #FFFFFF;font-size: 22rpx;letter-spacing: 1rpx;">可用积分</text>
					<image :src="wenhao" style="width: 22rpx;height: 22rpx;margin-left: 10rpx;"></image>
				</view>
				<view style="font-size: 40rpx;font-weight: bold;color: #FFFFFF;">{{jifen}}</view>
			</view>
		</view>
		<view style="width: 684rpx;padding: 36rpx;background: #FFFFFF;position: relative;left: 34rpx;border-radius: 31rpx;box-sizing: border-box;top: -116rpx;">
			<view style="display: flex;align-items: center;justify-content: space-between;">
				<view style="font-size: 29rpx;font-weight: bold;letter-spacing: 1rpx;">
					<text>已连续签到</text>
					<text style="font-size: 40rpx;font-weight: bold;color: #FF7300;">{{qiandaoDay}}</text>
					<text>天</text>
				</view>
				<view style="width: 200rpx;height: 50rpx;border-radius: 25rpx;line-height: 50rpx;text-align: center;color: #FFFFFF;font-size: 22rpx;" :class="isshow?'qian':'weiqian'" @tap="goqiandao">{{content}}</view>
			</view>
			<view style="border: 1rpx dashed #CACACA;margin: 20rpx 0;"></view>
			<view>
				<view style="display: flex;justify-content: space-between;margin-left: 5rpx;margin-bottom: 20rpx;">
					<view v-for="(itme,index) in arr" :key="index" style="display: flex;align-items: center;font-size: 25rpx;">第{{index + 1}}天</view>
				</view>
				<view style="display: flex;">
					<view v-for="(itme,index) in arr" :key="index" style="display: flex;align-items: center;position: relative;">
						<view style="height: 10rpx;width: 30rpx;background: #FFAE00;" v-if="index != 0"></view>
						<image :src="duihao" style="width: 64rpx;height: 64rpx;" v-if="qiandaoDay > index"></image>
						<image :src="wuzi" style="width: 64rpx;height: 64rpx;" v-if="qiandaoDay <= index"></image>
						<view style="position: absolute;top: 20rpx;font-size: 20rpx;color: #FFFFFF;" :class="index == 0? 'pingyi' : 'dayu'" v-if="qiandaoDay <= index">{{(index + 1)*10}}分</view>
					</view>
				</view>
			</view>
		</view>
		<view style="height: 700rpx;width: 750rpx;display: flex;align-items: center;position: relative;top: -10rpx;">
			<scroll-view style="height: 900rpx;width: 750rpx;box-sizing: border-box;position: relative;" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
				:refresher-threshold="0" refresher-background="#EE7B30" @refresherpulling="onPulling" @refresherrefresh="onRefresh" :scroll-top="scrollTop"  @scrolltolower="scrolltolower">
		<view style="height: 70rpx;width: 750rpx;display: flex;align-items: center;margin-left: 60rpx;position: relative;">
			<view style="width: 13.5rpx;height: 31rpx;background: #FF7300;"></view>
			<view style="font-size: 35rpx;font-weight: bold;margin-left: 10rpx;">做任务赚积分</view>
		</view>
		<view style="width: 684rpx;padding: 36rpx;background: #FFFFFF;position: relative;left: 34rpx;border-radius: 31rpx;box-sizing: border-box;">
			<view v-for="(itme,index) in renwu_xinxi" :key="index">
				<view style="display: flex;justify-content: space-between;align-items: center;font-size: 25rpx;">
					<view >{{itme.introduce}}</view>
					<view style="color: #FF7300;">{{itme.pic_path}}</view>
					<view style="width: 180rpx;height: 50rpx;border-radius: 25rpx;line-height: 50rpx;text-align: center;color: #FF7300;font-size: 22rpx;border: 1rpx solid #FF7300;">立即前往</view>
				</view>
				<view style="height: 2rpx;width: 100%;background: #F5F5F5;margin: 30rpx 0;" ></view>
			</view>
		</view>
		<view style="height: 70rpx;width: 750rpx;display: flex;align-items: center;position: relative;margin-left: 60rpx;">
			<view style="width: 13.5rpx;height: 31rpx;background: #FF7300;"></view>
			<view style="font-size: 35rpx;font-weight: bold;margin-left: 10rpx;">热销课程</view>
		</view>
		
				<view class="kecheng" style="display: flex;flex-wrap: wrap;margin: 20rpx 0 0 20rpx;width: 730rpx;">
					<view class="jigouke_jing" v-for="(itme,index) in jigou_ke" :key="index" @tap="gokechengxiang(itme)" style="margin:0 10rpx 10rpx 0;position: relative;background: #FFFFFF;box-sizing: border-box;padding: 0rpx 0rpx  35rpx 0rpx;border-radius: 15rpx;border: #C1C1C1 0.09rpx solid;">
						<view style="position: absolute;top: -1;left: -1;z-index: 12121;min-width: 70.7rpx;height: 35rpx;text-align: center;line-height: 35rpx;color: #FFFFFF;font-size: 20rpx;border-radius: 15rpx 0 15rpx 0 ;background: #FF3D3D;padding: 0 6rpx;">{{itme.label}}</view>
						<image :src="itme.face_url" mode="" style="width: 350rpx;height: 270rpx;border-radius: 15rpx;vertical-align: middle;margin: 0"></image>
						<view style="position: absolute;top: 178rpx;" v-if="itme.is_attend_activities">  
							<image :src="quan" style="width:350rpx;vertical-align: bottom;" mode="widthFix"></image>
						</view>
						
						<view style="font-size:28.146rpx;color: #292929;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;width: 270rpx;margin-top: 5rpx;">
							<text style="font-weight: bold;">【{{itme.course_num}}节】</text>
							<text>{{itme.title}}</text>
						</view>
						<view style="display: flex;justify-content: space-between;align-items: center;height: 37rpx;margin-left: 10rpx;">
							<view style="display: flex;align-items: center;position: relative;">
								<view style="color: #FF3D3D;font-weight:bold ;" v-if="itme.map.activityEntity != null" >
									<text style="font-size:20rpx;">￥</text>
									<text style="font-size:30rpx;margin: 0 5rpx;">{{itme.map.activityEntity.price}}</text>
									<text style="font-size:20rpx;">/ 节</text>
								</view>
								<view style="font-weight:bold ;height: 37rpx;" v-if="itme.map.priceList.length != 0" :class="itme.map.activityEntity != null ? 'panduan' :'zhengchang'">
									<text style="font-size:20rpx;">￥</text>
									<text style="margin: 0 5rpx;">{{itme.map.priceList[0].price}}</text>
									<text style="font-size:20rpx;">/ 节</text>
								</view>
							</view>
						</view>
						<view style="font-size:26rpx;color: #C1C1C1;height: 26rpx;position: relative;top: 10rpx;left: 10rpx;">{{itme.pay_num}}人已购买</view>
					</view>
				</view>
				<view style="height: 100rpx;width: 100%;margin: 30rpx 0;font-size: 25rpx;border-top: 2rpx solid #BEBEBE;text-align: center;line-height: 100rpx;" v-if="isshow_">
					暂无数据
				</view>
			</scroll-view>
		</view>
	</view>
</template>
<script>
	export default {
		data(){
			return {
				img: "http://img.curiousmore.com/636455",
				user_id: "",
				wenhao: "http://img.curiousmore.com/673957",
				jifen: "",
				qiandaoDay: "",
				content: "",
				isshow: "",
				arr: [1,1,1,1,1,1,1],
				duihao: "http://img.curiousmore.com/937964",
				wuzi: "http://img.curiousmore.com/585641",
				renwu_xinxi: [],
				jigou_ke: [],
				num: 1,
				triggered: false,
				biao_num: 1,
				shua: 1,
				// quan: {},
				isshow_: false,
				quan: "http://img.curiousmore.com/65584"
			}
		},
		methods: {
		async	jifenshu(){
				const res = await this.$myRequest({
					url: "/userInfo/queryTeachPayUserStatistics",
					data: {
						user_id: this.user_id
					}
				})
				this.jifen = res.data.points
			},
		async	renwu(){
				const res = await this.$myRequest({
					url: "/userGoldType/queryTeachPaypal",
					data: {
						is_teach_paypal: true,
						status: 1,
						user_id: this.user_id
					}
				})
				this.renwu_xinxi = res.data
			},
		async	qiandaotong(){
				const res = await this.$myRequest({
					url: "/signIn/queryTeachPaypalDetail",
					data: {
						user_id: this.user_id
					}
				})
				this.qiandaoDay = res.data.singInDay
				if(res.data.todaySignIn){
					this.content = "已签到"
					this.isshow = true
				}else{
					this.content = "签到领积分"
					this.isshow = false
				}
			},
		async	goqiandao(){
				const res = await this.$myRequest({
					url: "/signIn/insertLogin",
					data: {
						user_id: this.user_id
					}
				})
				if(res.code == 0){
					
					if(this.isshow){
						uni.showToast({
							title: "已签到",
							icon: "none"
						})
					}else{
						uni.showToast({
							title: "签到成功"
						})
						this.jifenshu()
						this.qiandaotong()
					}
				}
			},
			async	xin(){
				    let _this = this
					uni.showLoading({
						title:"加载中"
					})
					const res = await _this.$myRequest({
						url:"/masterSetPrice/queryNearByCourse",
						data:{
							pageSize:10,
							currentPage: _this.num,
							latitude: _this.weidu,
							longitude: _this.jingdu,
							status: 2,
							type: "mechanism_offline"
						},
					})
					if(res.data.length < 10){
						_this.biao_num = 2
						uni.showToast({
							title: "无数据"
						})
					}else{
						_this.biao_num = 1
					}
					if(_this.jigou_ke.length == 0){
						_this.jigou_ke = res.data
					}else{
						_this.jigou_ke = _this.jigou_ke.concat(res.data)
					}
					_this.triggered = false
					uni.hideLoading()
				},
				gokechengxiang(itme){
					uni.navigateTo({
					    url: '/pages/World/classChannel/classChannel?curriculumId=' + itme.id
					})
				},
				onRefresh(){
					this.isshow_ = false
					this.num = 1
					this.triggered = true
					this.jigou_ke = []
					this.xin()
				},
				scrolltolower(){
					if(this.biao_num == 1){
						this.num++
						this.xin()
					}else{
						this.isshow = true
						uni.showToast({
							title: "加载完毕",
							duration: 2000,
							icon: "none"
						})
					}
				}
		},
		onLoad() {
			try{
				this.user_id = uni.getStorageSync('userif_list').user_id
				const val = uni.getStorageSync('storage_key')
				if(uni.getStorageSync('kaquan')){
					this.quan = uni.getStorageSync('kaquan')
				}
				this.weidu = val.latitude
				this.jingdu = val.longitude
				this.xin()
			}catch(e){}
			this.jifenshu()
			this.renwu()
			this.qiandaotong()
		}
	}
</script>
<style lang="scss" scoped>
	.qian{
		background: #CACACA;
	}
	.weiqian{
		background: #FF7300;
	}
	.pingyi{
		left: 15rpx;
	}
	.dayu{
		left: 40rpx;
	}
	.panduan{
		color: #BFBFBF;
		text-decoration:line-through ;
		margin-left: 10rpx;
		font-size: 25rpx;
		margin-top: 15rpx;
	}
	.zhengchang{
		color:#FF3D3D;
		font-size: 30rpx;
	}
</style>